<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ include file="admin_menu.jsp" %>
    <!--/sidebar-->
    <div class="main-wrap">

        <div class="crumb-wrap">
            <div class="crumb-list"><i class="icon-font"></i><a href="admin_index.jsp">首页</a><span class="crumb-step">&gt;</span><span class="crumb-name">用户管理</span></div>
        </div>
        <div class="search-wrap">
            <div class="search-content">
                <form action="admin_douserselect" method="get">
                    <table class="search-tab">
                        <tr>
                            <th width="70">关键字:</th>
                            <td><input class="common-text" placeholder="关键字" name="keywords" value="${param.keywords }" id="" type="text"></td>
                            <td><input class="btn btn-primary btn2" value="查询" type="submit"></td>
                        </tr>
                    </table>
                </form>
            </div>
        </div>
        <div class="result-wrap">
            <form name="myform" id="myform" method="post" action="admin_douserdel">
                <div class="result-title">
                    <div class="result-list">
                        <a href="admin_useradd.jsp"><i class="icon-font"></i>新增用户</a>
                        <a id="batchDel" href="javascript:delpart('确定删除这些用户吗？','myform')"><i class="icon-font"></i>批量删除</a>
                    </div>
                </div>
                <div class="result-content">
                    <table class="result-tab" width="100%">
                        <tr>
                            <th class="tc" width="5%"><input class="allChoose" onclick="chooseall(this)" name="" type="checkbox"></th>
                            <th>ID</th>
                            <th>姓名</th>
                            <th>性别</th>
                            <th>邮箱</th>
                            <th>手机</th>
                            <th>操作</th>
                        </tr>
                        <c:forEach var="u" items="${userlist}">
	                        <tr>
	                            <td class="tc"><input name="user" value="${u.user_id}" type="checkbox"></td>
	                            <td>${u.user_id }</td>
	                            <td>${u.user_name }</td>
	                            <td>${u.user_sex=='T'?'男':'女' }</td>
	                            <td>${u.user_email }</td>
	                            <td>${u.user_mobile }</td>
	                            <td>
	                                <a class="link-update" href="admin_touserupdate?id=${u.user_id}&curPage=${curPage}">修改</a>
	                               	
	                                <c:if test="${u.user_status == 1}">
	                                	<a class="link-del" href="javascript:deluser( '确定删除【${u.user_id}】吗' , 'admin_douserdel?id=${u.user_id}&curPage=${curPage}' )">删除</a>
	                           		</c:if>
	                            </td>
	                        </tr>
	                    </c:forEach>
	                    
	                    <script>
	                    	function deluser(mess,url){
	                    		if(confirm(mess)){
	                    			location.href = url
	                    		}
	                    	}
	                    	
	                    	function chooseall(obj){
	                    		let user = document.getElementsByName('user')
	                    		for(let i = 0;i < user.length;i++){
	                    			user[i].checked = obj.checked
	                    		}
	                    	}
	                    	
	                    	function delpart(mes,formid){
	                    		let flag = 0
	                    		let user = document.getElementsByName('user')
	                    		for(let i = 0;i < user.length;i++){
	                    			if(user[i].checked==true){
	                    				flag++
	                    				break
	                    			}
	                    		}
	                    		if(flag===0){
	                    			alert("未选中")
	                    		}else if(confirm(mes)){
	                    			let form = document.getElementById(formid)
	                    			form.submit()
	                    		}
	                    	}
	                    </script>
                    </table>
                    <div class="list-page">
                    	共${sum}条记录，当前${curPage}/${pages}页
                    	<a href="admin_douserselect?tarpage=1${searParams}">首页</a>
                    	<a href="admin_douserselect?tarpage=${curPage-1<1?1:curPage-1}${searParams}">上一页</a>
                    	<a href="admin_douserselect?tarpage=${curPage+1>pages?pages:curPage+1}${searParams}">下一页</a>
                    	<a href="admin_douserselect?tarpage=${pages}${searParams}">尾页</a>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
</body>
</html>